package com.md24housecall.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

public class TagUser implements Parcelable {

	public String _ID;
	public String _user_login;
	public String _user_pass;
	public String _user_nicename;
	public String _user_email;
	public String _user_url;
	public String _user_registered;
	public String _user_activation_key;
	public String _user_status;
	public String _display_name;
	public String _user_code;
	public int _expired_code;
	
	public TagUser() {
		_ID = "";
		_user_login = "";
		_user_pass = "";
		_user_nicename = "";
		_user_email = "";
		_user_url = "";
		_user_registered = "";
		_user_activation_key = "";
		_user_status = "";
		_display_name = "";
		_user_code = "";
		_expired_code = -1;
	}
	
	/** Constructor with data from Parcel */
	public TagUser(Parcel in) {
		this._ID = in.readString();
		this._user_login = in.readString();
		this._user_pass = in.readString();
		this._user_nicename = in.readString();
		this._user_email = in.readString();
		this._user_url = in.readString();
		this._user_registered = in.readString();
		this._user_activation_key = in.readString();
		this._user_status = in.readString();
		this._display_name = in.readString();
		this._user_code = in.readString();
		this._expired_code = in.readInt();
		
	}
	
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(_ID);
		dest.writeString(_user_login);
		dest.writeString(_user_pass);
		dest.writeString(_user_nicename);
		dest.writeString(_user_email);
		dest.writeString(_user_url);
		dest.writeString(_user_registered);
		dest.writeString(_user_activation_key);
		dest.writeString(_user_status);
		dest.writeString(_display_name);
		dest.writeString(_user_code);
		dest.writeInt(_expired_code);
	}
	
	public static final Parcelable.Creator<TagUser> CREATOR = new Parcelable.Creator<TagUser>() {
		public TagUser createFromParcel(Parcel in) {
			return new TagUser(in); 
		}
		public TagUser[] newArray(int size) {
			return new TagUser[size];
		}
	};
	
	@Override
	public String toString() {
		return "@id=" + _ID + " @user_login=" + _user_login +
				" @email=" + _user_email + " @Name=" + _display_name +
				" @code=" + _user_code + " @expire=" + _expired_code;
	}

	@Override
	public int describeContents() {
		return 0;
	}
	
	public boolean isCodeExpired() {
		return _expired_code != 0;
	}
	
	public boolean isUserEmpty() {
		return TextUtils.isEmpty(_ID) && TextUtils.isEmpty(_user_code);
	}
}
